var fs=require('fs');


fs.readdir(process.cwd(), function (err, files) {
   console.log('');

    if(!files.length){
        return console.log('No files to show!');
    }

    console.log('Select which file or directory you want to see\n');

    function file(i){
        var name=files[i];
        fs.stat(__dirname+'/'+name, function (err, st) {
            if(st.isDirectory()){
                console.log('Dir:'+name);
            }else{
                console.log('File:'+name);
            }

            i++;
            if(i==files.length){
                console.log('');
                process.stdout.write('Enter your choice:');
                process.stdin.resume();
                process.stdin.setEncoding('utf8');
            }else{
                file(i);
            }
        });
    }
    file(0);

});